import { defineStore } from 'pinia'

import {getCookie} from '../function/Cookie '
export const useCounterStore = defineStore('counter', {
  state: () => ({
    Cookie: getCookie('sharingToken') || null,
    userid:'',
    userXx:{},
    integral:{
        Integralid:'',
        Integral:'0'
      },
    blance:{
        balanceid:'',
        balance:'0.00'
      },
    winscrooll:0,
    sigin:'0',
    //在进入的时候就会直接请求的数据  
    publidata:{
      permissiontypelist:[],//文档权限类型数组
      fromlablelist:[],//文档标签数组
    },
  }),
  actions: {
  loginset(userid,userXx,Cookie){
   this.userid=userid
   this.userXx=userXx
   this.Cookie=Cookie
  },
  changepublidata(typelist,data){
    typelist.forEach((item)=>{
    if(item)this.publidata[item]=data[item]
    })
  },
  listenwinscrooll(value){
    this.winscrooll=value
  },
  changeintegral(type,data){
     this.integral={
      Integralid:data.Integralid,
      Integral:data.integral
     }
  },
  changeblance(type,data){
     this.blance={
      balanceid:data.balanceid,
      balance:data.balance
     }
  },
  changeData(type,data){
    this[type]=data
  }
  },
  getters: {
  }
})